//
//  HYButton.m
//  Object-CPlayGround
//
//  Created by 韩丛旸 on 16/8/3.
//  Copyright © 2016年 韩丛旸. All rights reserved.
//

#import "HYButton.h"

@implementation HYButton
{
    NSDate *touchTime;
    NSDate *sendActionTime;
}

- (instancetype)init
{
    self = [super init];
    if (self)
    {
        sendActionTime = [NSDate dateWithTimeIntervalSinceNow:-10.0f];
    }
    return self;
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [super touchesBegan:touches withEvent:event];
    touchTime = [NSDate date];
}


- (void)sendAction:(SEL)action to:(id)target forEvent:(UIEvent *)event
{
    if ([[NSDate date] timeIntervalSinceDate:touchTime] < 5.0f &&
        [[NSDate date] timeIntervalSinceDate:sendActionTime] > 1.0f)
    {
        [super sendAction:action to:target forEvent:event];
        sendActionTime = [NSDate date];
    }
}

- (BOOL)beginTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event
{
    NSLog(@"%@", event);
    NSLog(@"%@", touch);

    return YES;
}


@end
